import Notification from './Notification.vue'

export default {
    extends : Notification,
    computed: {
        style(){
            return {
                position : 'fixed',
                right : '20px',
                [this.position]: `${this.verticalOffset}px`
            }
        }
    },
    data(){
        return {
            verticalOffset: 0,
            duration : this.duration
        }
    },
    mounted() {
        // console.log(this.position)
        // console.log(this.duration)
    },
    created(){
        this.createTimer()
    },
    destroyed() {
        this.clearTimer()
    },
    methods : {
        createTimer(){
            if(this.duration == 0){
                return false
            }
            this.timer = setTimeout( () => {
                this.visible = false
                this.$emit('removeInstance',this.id)
            },this.duration)
        },
        clearTimer(){
            if(this.timer){
                clearTimeout(this.timer)
            }
        },
        handleDele(e){
            e.preventDefault()
            this.$emit('removeInstance',this.id)
            this.clearTimer(this.timer)
        },
        handleMouseLeave(){
            this.createTimer()
        },
        handleMouseEnter(){
            this.clearTimer()
        }
    }
    
}